<?php

namespace app\common\validate;

use think\Validate;

class Order extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'user_id'       => 'require|number',
        'region_id'     => 'number',
        'address_id'    => 'number',
        'address'       => 'require|length:1,255',
        'username'      => 'require|length:1,20',
        'mobile'        => 'require|regex:^1[0-9]{10}$',
        'remarks'       => 'length:0,255',
        'lng'           => 'require|float',
        'lat'           => 'require|float',
        'weight_type'   => 'require|between:1,3',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'user_id'               => '下单用户不能为空',
        'user_id.number'        => '下单用户错误',
        'region_id.number'      => '订单区域错误',
        'address_id.number'     => '用户地址错误',
        'address'               => '地址不能为空',
        'address.length'        => '地址长度范围 1~255个字符',
        'username'              => '姓名不能为空',
        'username.length'       => '姓名长度范围 1~20个字符',
        'mobile'                => '联系电话不能为空',
        'mobile.regex'          => '联系电话格式错误',
        'remarks.length'        => '备注长度范围 0~255个字符',
        'lng'                   => '地址经度不能为空',
        'lng.float'             => '地址经度格式错误',
        'lat'                   => '地址纬度不能为空',
        'lat.float'             => '地址纬度格式错误',
        'weight_type'           => '请选择重量类型',
    ];

    /**
     * 字段描述
     */
    protected $field = [

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['user_id', 'region_id', 'address_id', 'address', 'username', 'mobile', 'remarks', 'lng', 'lat', 'weight_type'],
    ];
}